// 全局组件注册
import SvgIcon from './SvgIcon/index.vue'
import * as ElementPlusIconsVue from '@element-plus/icons-vue' //引入element-plus的图标库
import type { App, Component } from 'vue'

const allGlobalComponents: { [name: string]: Component } = {
    SvgIcon: SvgIcon,
    ...ElementPlusIconsVue, //将element-plus的图标库注册为全局组件
}

export default {
    //当main.ts中执行app.use(gloablComponent)时，会执行install方法
    install(app: App) {
        Object.keys(allGlobalComponents).forEach((key: string) => {
            app.component(key, allGlobalComponents[key]) //app.component是vue3中全局注册组件的方法
        })
    },
}
